nlp_architect.models.intent_extraction.MultiTaskIntentModel

class nlp_architect.models.intent_extraction.MultiTaskIntentModel(use_cudnn=False)[source]

Multi-Task Intent and Slot tagging model (using tf.keras)

Parameters:use_cudnn (bool, optional) – use GPU based model (CUDNNA cells)
__init__(use_cudnn=False)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([use_cudnn]) Initialize self.
build(word_length, num_labels, …[, …]) Build a model
fit(x, y[, epochs, batch_size, callbacks, …]) Train a model given input samples and target labels.
load(path) Load a trained model
load_embedding_weights(weights) Load word embedding weights into the model embedding layer
predict(x[, batch_size]) Get the prediction of the model on given input
save(path) Save model to path

Attributes

input_shape Get input shape
build(word_length, num_labels, num_intent_labels, word_vocab_size, char_vocab_size, word_emb_dims=100, char_emb_dims=30, char_lstm_dims=30, tagger_lstm_dims=100, dropout=0.2)[source]

Build a model

Parameters:
  • word_length (int) – max word length (in characters)
  • num_labels (int) – number of slot labels
  • num_intent_labels (int) – number of intent classes
  • word_vocab_size (int) – word vocabulary size
  • char_vocab_size (int) – character vocabulary size
  • word_emb_dims (int, optional) – word embedding dimensions
  • char_emb_dims (int, optional) – character embedding dimensions
  • char_lstm_dims (int, optional) – character feature LSTM hidden size
  • tagger_lstm_dims (int, optional) – tagger LSTM hidden size
  • dropout (float, optional) – dropout rate
fit(x, y, epochs=1, batch_size=1, callbacks=None, validation=None)

Train a model given input samples and target labels.

Parameters:
  • x – input samples
  • y – input sample labels
  • epochs (int, optional) – number of epochs to train
  • batch_size (int, optional) – batch size
  • callbacks (Callback, optional) – Keras compatible callbacks
  • validation (list of numpy.ndarray, optional) – optional validation data to be evaluated when training
input_shape

Get input shape

Type:tuple
load(path)

Load a trained model

Parameters:path (str) – path to model file
load_embedding_weights(weights)

Load word embedding weights into the model embedding layer

Parameters:weights (numpy.ndarray) – 2D matrix of word weights
predict(x, batch_size=1)

Get the prediction of the model on given input

Parameters:
  • x – samples to run through the model
  • batch_size (int, optional) – batch size:
Returns:

predicted values by the model

Return type:

numpy.ndarray

save(path)[source]

Save model to path

Parameters:path (str) – path to save model